# Replication Package: Demographics and the Resource Economy: How Commodities Amplify the Lifecycle

**Paper 27 in the Demographics & Global Capital Allocation series**
**Brian Peters, March 2026**

---

## Overview

This paper tests whether resource rents amplify or mask the demographic current account channel. Key findings: hydrocarbon rents amplify, rather than mask, the CA slope (Z₁ × resource interaction = +0.154***), but the interaction has weakened 81% since 2000 due to SWF institutionalization. The result is scope-limited to MENA/hydrocarbon exporters; mineral rents show no interaction.

## Software Requirements

- Python 3.10+
- Required packages: `numpy`, `pandas`, `statsmodels`, `scipy`, `matplotlib`, `python-docx`
- Install: `pip install numpy pandas statsmodels scipy matplotlib python-docx`

## Directory Structure

```
replication/
  REPLICATION_README.md
  scripts/
    phase2_commodity_data.py     # Commodity interaction regressions
    phase3_commodity_deep_dive.py # Hydrocarbon vs mineral decomposition
    phase3b_gravity_fix.py       # Bilateral gravity with commodity controls
    phase3c_remaining.py         # Additional commodity specifications
    phase4_price_volume.py       # Price vs volume decomposition
    phase5_robustness.py         # Robustness battery
    phase6_revisions.py          # Revision-round robustness
    probe_threshold_crossing.py  # Resource threshold analysis
    build_docx.py                # DOCX generation
  src/
    model.py                     # PanelGLS estimator (shared across series)
    [other shared modules]
  data/processed/
    full_panel_with_resources.csv # Augmented panel with resource rents + interactions
  output/tables/
    commodity_interactions.md    # Main interaction results
    [additional CSV/MD tables]
  paper/
    paper.md                     # Manuscript source
```

## Reproduction

Run scripts in order:
```bash
python3 scripts/phase2_commodity_data.py
python3 scripts/phase3_commodity_deep_dive.py
python3 scripts/phase3b_gravity_fix.py
python3 scripts/phase3c_remaining.py
python3 scripts/phase4_price_volume.py
python3 scripts/phase5_robustness.py
python3 scripts/phase6_revisions.py
```

**Note:** Scripts use absolute paths (`/mnt/c/demographics_capital_flows/...`). Update the path references at the top of each script for your local environment. Some scripts reference data from the multilateral (Paper 1) and gravity bilateral (Paper 2) directories.

## Data Sources

- UN World Population Prospects (2024 Revision) — age distributions
- World Bank WDI — total resource rents, oil/gas/mineral rents (% GDP)
- IMF WEO — current account, fiscal balance, GDP
- Penn World Table 10.01 — output per worker
- Chinn-Ito KAOPEN — capital account openness
- Lane-Milesi-Ferretti — net foreign assets
- IMF CPIS — bilateral portfolio positions (for gravity specifications)
